package cn.micai.base.concurrent;

import java.util.Vector;

/**
 * @Auther: zhaoxinguo
 * @Date: 2018/7/5 17:48
 * @Description: 扩展的Vector包含一个"缺少即添加"方法
 */
public class BetterVector<E> extends Vector<E> {

    public synchronized boolean putIfAbsent(E x) {
        boolean absent = !contains(x);
        if (absent) {
            add(x);
        }
        return absent;
    }
}
